from api.bumen_api import BuMen
from common import assert_tools
from common.token01 import login


class Testquer:
    def setup(self):
        b = BuMen()
        headers = login()
        resp = b.add(headers, {"name": "123456", "code": "456789"})
        f = resp.json().get("data").get("id")
        return f
    def test01(self):
        b = BuMen()
        headers = login()
        resp = b.add(headers,{"name":"123456","code":"456789"})
        print(resp.json())
        assert_tools.assert_tools(resp,200, True,10000,"操作成功")

    def test02(self):
        b = BuMen()
        headers = login()
        resp2 = b.query(self.setup(), headers)
        print(resp2.json())
        assert_tools.assert_tools(resp2, 200, True, 10000, "操作成功")
    def test03(self):
        b = BuMen()
        headers = login()
        resp2 = b.put(self.setup(),headers,{"name":"李莉莉"})
        print(resp2.json())
        assert_tools.assert_tools(resp2,200,True,10000,"操作成功")
    def test04(self):
        b = BuMen()
        headers = login()
        resp2 = b.delete0(self.setup(), headers)
        print(resp2.json())
        assert_tools.assert_tools(resp2,200,True,10000,"操作成功")